#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define vec vector<int>
#define y1 y_____hahahaha_____1

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;

int read(){int x = 0,sgn = 1;char ch = getchar();for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;for(;isdigit(ch);ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48); return x * sgn;}

const int N = 110;
const ll inf = 1e15;

ll cost[N][N],dis[N],f[N];
int n,m,e,K;
bool vis[N],ban[N];
vec day[N];
vector<pii> G[N];

void spfa(){
	queue<int> q; q.push(1); memset(vis,0,sizeof vis); memset(dis,0x3f,sizeof dis); dis[1] = 0;
	while(!q.empty()){
		int x = q.front(); q.pop(); vis[x] = 0;
		for(auto d : G[x])
			if(!ban[d.fi] && dis[d.fi] > dis[x] + d.se) dis[d.fi] = dis[x] + d.se,vis[d.fi] == 0 ? q.push(d.fi),vis[d.fi] = 1 : 0;
	}
}

int main(){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,m = in,K = in,e = in;
	for(int i = 1,u,v,w;i <= e;i++) u = in,v = in,w = in,G[u].pb({v,w}),G[v].pb({u,w}); int d = in;
	for(int i = 1,p,a,b;i <= d;i++) {p = in,a = in,b = in; for(int j = a;j <= b;j++) day[j].pb(p);}
	for(int i = 1;i <= n;i++)
		for(int j = i;j <= n;j++){
			memset(ban,0,sizeof ban); for(int k = i;k <= j;k++) for(auto x : day[k]) ban[x] = 1;
			spfa(); cost[i][j] = dis[m];
		}
	memset(f,0x3f,sizeof f); f[0] = 0;
	for(int i = 1;i <= n;i++) for(int j = 0;j < i;j++) if(cost[j + 1][i] < inf) f[i] = min(f[i],f[j] + cost[j + 1][i] * (i - j) + (j == 0 ? 0 : 1) * K);
	printf("%lld\n",f[n]);
	return 0;
}
